package com.heima.user.controller;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.UserRelationDto;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.IApUserFollowService;
import com.heima.user.service.IApUserService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * APP用户关注信息表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-07-04
 */
@RestController
@RequestMapping("/api/v1/user")
@AllArgsConstructor
public class ApUserFollowController {
    @Autowired
    private IApUserService apUserService;

    private final IApUserFollowService apUserFollowService;

    @PostMapping("/user_follow")
   public ResponseResult followOrUnFollow(@RequestBody UserRelationDto dto) {
        return apUserFollowService.followOrUnfollow(dto);
    }

    @PostMapping("/is_follow")
    public Boolean isFollows(@RequestBody UserRelationDto dto) {
        return apUserFollowService.isFollow(dto);
    }

    @GetMapping("/{id}")
    public ApUser getUserById(@PathVariable("id") Integer id) {
        return apUserService.getById(id);
    }
}
